package com.twu.biblioteca.command;

import com.twu.biblioteca.User;
import com.twu.biblioteca.UsersManager;

/**
 * Created with IntelliJ IDEA.
 * User: twer
 * Date: 5/30/13
 * Time: 2:17 PM
 * To change this template use File | Settings | File Templates.
 */
public class CheckMemberShipCommand implements Command {
    private UsersManager userManager;

    public CheckMemberShipCommand(UsersManager userManager) {
        this.userManager = userManager;
    }

    @Override
    public String execute() {
        User user;
        if((user = userManager.getLoginUser()) != null){
            StringBuilder sb = new StringBuilder();
            sb.append("name: ").append(user.getName()).append("\n");
            sb.append("email: ").append(user.getEmail()).append("\n");
            sb.append("phone: ").append(user.getPhone()).append("\n");
            return sb.toString();
        }
        return "Please talk to a Librarian. Thank you.";
    }
}
